package com.zhangji.springcloud.service;

import com.zhangji.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: Hystrix 服务降级
 * @Author: Zhang Ji
 * @Date: 2021/6/28 17:19
 * Created by IntelliJ IDEA.
 */
@Component
public class DeptClientServerFallback implements FallbackFactory {

    @Override
    public DeptClientServer create(Throwable throwable) {
        return new DeptClientServer() {
            @Override
            public Dept queryById(Long id) {
                return new Dept().setDept_no(id).setDept_name("服务降级，服务被关闭").setDb_source("你不对劲");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }

}
